package com.atlin.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Option;

import java.util.concurrent.Callable;

/**
 * @author atlin
 * @description
 * @createDate 2024/9/23 8:48
 */
public class Login implements Callable<Integer> {

    @Option(names = {"-u", " --user"}, description = "用户名")
    String user;

    @Option(names = {"-p", "--password"}, arity = "0..1", description = "密码", interactive = true)
    String password;

    @Option(names = {"-cp", " --checkPassword"}, arity = "0..1", description = "确认密码", interactive = true)
    String checkPassword;

    @Override
    public Integer call() throws Exception {
        System.out.println("用户名：" + user);
        System.out.println("密码：" + password);
        System.out.println("确认密码：" + checkPassword);
        return 0;
    }

    public static void main(String[] args) {
//        new CommandLine(new Login()).execute("-u", "user123", "-p", "123", "-cp", "456");
        new CommandLine(new Login()).execute("-u", "user123", "-p", "-cp");
    }
}
